package com.ztsoft.user.utils;

import com.ztsoft.user.pojo.entity.project.Choose;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.factory.annotation.Value;

import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;

public class WordUtils {
    @Value("${file.bidResultTable}")
    private String bidResultTable;

    //赣州中选通知书
    public static String createWordGanZhou(List<Choose> data, XWPFDocument doc) throws Exception {
        String fileName = "C:\\dataFile\\bidResultTable\\" + data.get(0).getSubcontracted() + data.get(0).getPackageName() + "-" + data.get(0).getBatch() + "-" + data.get(0).getOrdersNumber() + "-" + data.get(0).getOrderId() + ".docx";
        {
            XWPFParagraph p = doc.createParagraph();
            //设置分页符
//            p.setPageBreak(true);
            //创建段落================标题
            XWPFParagraph paragraph = doc.createParagraph();
            //设置对齐
            paragraph.setAlignment(ParagraphAlignment.LEFT);
            XWPFRun run = paragraph.createRun();
 /*           run.setColor("000000");
            run.setText("附件:");
            run.setFontFamily("黑体");
            run.setFontSize(16);
            run.setBold(true);*/
            //换行
            //run.addBreak();
            // 表格
            XWPFTable table = doc.createTable(data.size() + 2, 14);
            //表格属性
            CTTblPr tablePr = table.getCTTbl().addNewTblPr();
            //表格宽度
            CTJc cTJc = tablePr.addNewJc();
            //居中
            cTJc.setVal(STJc.CENTER);
            //列宽自动分割
            CTTblWidth tableWidth = tablePr.addNewTblW();
            //设置表格宽度
            tableWidth.setType(STTblWidth.DXA);
            tableWidth.setW(BigInteger.valueOf(15000));
            //========================================第一行===================================
            //设置单元格宽度
            XWPFTableRow carRow1 = table.getRow(0);
            //设置单元格高度
            carRow1.setHeight(500);
            //设置单元格宽度
            carRow1.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));

            //以创建段落的方式给单元格赋值
            List<XWPFParagraph> paragraphs = carRow1.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            XWPFRun run1 = paragraphs.get(0).createRun();
            run1.setText("序号");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(1).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("工程名称");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(2).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("网省采购申请号");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(3).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物料编码");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(4).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物资类别");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(2000));
            paragraphs = carRow1.getCell(5).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物料描述");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(6).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("扩展描述");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(7).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("单位");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(8).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("数量");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(9).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(9).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税单价（元）");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(9).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(10).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税总价（元）");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(11).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(11).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("项目单位");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(11).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(12).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(12).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("交货日期");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(12).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(13).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(13).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("备注");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(13).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            BigDecimal totalPrice = new BigDecimal(Double.toString(0.00));
            for (int i = 0; i < data.size(); i++) {
                XWPFTableRow carRow3 = table.getRow(i + 1);

                carRow3.setHeight(500);
                carRow3.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
                paragraphs = carRow3.getCell(0).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("" + (i + 1));
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(1).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();

                //工程名称拆分，每行5个字
                String[] splitProjectName = data.get(i).getProjectName().split("(?<=\\G.{5})");
                for (String s : splitProjectName) {
                    run1.setText(s);
                    run1.addBreak();
                }
//                run1.setText(data.get(i).getProjectName());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(2).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                if (data.get(i).getPurchase() != null) {
                    run1.setText(data.get(i).getPurchase().substring(0, data.get(i).getPurchase().length() / 2));
                    run1.addBreak();
                    run1.setText(data.get(i).getPurchase().substring(data.get(i).getPurchase().length() / 2));
                }
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(3).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getMaterialCode());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(4).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getMaterialCategory());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(2000));
                paragraphs = carRow3.getCell(5).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getDescribes());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(6).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getExtend());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(7).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getUnit());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(8).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getQuantity().toString());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(9).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(9).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getFinalUnitPrice());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(9).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                BigDecimal matchingQuota = new BigDecimal(data.get(i).getMatchingQuota().toString());
                carRow3.setHeight(500);
                carRow3.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(10).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(matchingQuota.toString());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(11).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(11).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                //需求单位名称，一行5个字
                String[] split = data.get(i).getDemandUnit().split("(?<=\\G.{5})");
                for (String s : split) {
                    run1.setText(s);
                    run1.addBreak();
                }
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(11).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(12).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(12).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                //交货时间1行5字
                String[] deliveryDate = data.get(i).getDeliveryDate().split("(?<=\\G.{5})");
                for (String s : deliveryDate) {
                    run1.setText(s);
                    run1.addBreak();
                }
//                run1.setText(data.get(i).getDeliveryDate());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(12).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(13).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(13).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getNotes());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(13).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                totalPrice = totalPrice.add(matchingQuota);
            }
            XWPFTableRow carRow4 = table.getRow(data.size() + 1);
            carRow4.setHeight(500);
            carRow4.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
            paragraphs = carRow4.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("合计");
            run1.setFontSize(7);
            run1.setBold(true);
            run1.setFontFamily("微软雅黑");
            run1.setColor("000000");
            carRow4.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            for (int i = 1; i < 10; i++) {
                carRow4.setHeight(500);
                if (i == 4)
                    carRow4.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(2000));
                else
                    carRow4.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow4.getCell(i).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("");
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setBold(true);
                run1.setColor("000000");
                carRow1.getCell(i).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }

            carRow4.setHeight(500);
            carRow4.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow4.getCell(10).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText(totalPrice.toString());
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setColor("000000");
            run1.setBold(true);
            carRow4.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            for (int i = 11; i < 14; i++) {
                carRow4.setHeight(500);
                carRow4.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow4.getCell(i).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("");
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setBold(true);
                run1.setColor("000000");
                carRow1.getCell(i).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }
            //合并列
            mergeHorizontal(table, data.size() + 1, 0, 9);
            mergeHorizontal(table, data.size() + 1, 11, 13);
            //合并行
            mergeVertically(table, 1, 1, data.size());
            mergeVertically(table, 11, 1, data.size());
            mergeVertically(table, 12, 1, data.size());
            mergeVertically(table, 13, 1, data.size());
            //输出到C盘
            FileOutputStream os = new FileOutputStream(fileName);
            doc.write(os);
            os.close();
        }
        return fileName;
    }

    //导出审批表
    public static String approvalWordGanZhou(List<Choose> data, XWPFDocument doc) throws Exception {
        String fileName = "C:\\dataFile\\bidResultTable\\" + data.get(0).getDemandUnit() + "匹配审批表.docx";
        {
/*            XWPFParagraph p = doc.createParagraph();
            //设置分页符
            p.setPageBreak(true);*/
            //创建段落================标题
            XWPFParagraph paragraph = doc.createParagraph();
            //设置对齐
            paragraph.setAlignment(ParagraphAlignment.LEFT);
            // 表格
            XWPFTable table = doc.createTable(data.size() + 1, 13);
            //表格属性
            CTTblPr tablePr = table.getCTTbl().addNewTblPr();
            //表格宽度
            CTJc cTJc = tablePr.addNewJc();
            //居中
            cTJc.setVal(STJc.CENTER);
            //列宽自动分割
            CTTblWidth tableWidth = tablePr.addNewTblW();
            //设置表格宽度
            tableWidth.setType(STTblWidth.DXA);
            tableWidth.setW(BigInteger.valueOf(15000));
            //========================================第一行===================================
            //设置单元格宽度
            XWPFTableRow carRow1 = table.getRow(0);
            //设置单元格高度
            carRow1.setHeight(500);
            //设置单元格宽度
            carRow1.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));

            //以创建段落的方式给单元格赋值
            List<XWPFParagraph> paragraphs = carRow1.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            XWPFRun run1 = paragraphs.get(0).createRun();
            run1.setText("序号");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(1).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("分标编号");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(2).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("分标名称");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(3).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("网省采购申请号");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(4).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物资类别");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(5).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物料描述");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(6).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("扩展描述");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(7).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("工程项目名称");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
            paragraphs = carRow1.getCell(8).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("单位");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(9).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
            paragraphs = carRow1.getCell(9).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("数量");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(9).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(10).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税单价（元）");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(11).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(11).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税总价（元）");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(11).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(12).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
            paragraphs = carRow1.getCell(12).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("备注");
            run1.setFontSize(8);
            run1.setFontFamily("微软雅黑");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(12).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            for (int i = 0; i < data.size(); i++) {
                XWPFTableRow carRow3 = table.getRow(i + 1);

                carRow3.setHeight(500);
                carRow3.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
                paragraphs = carRow3.getCell(0).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("" + (i + 1));
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(1).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                if (data.get(i).getPurchase() != null) {
                    run1.setText(data.get(i).getSubcontract().substring(0, data.get(i).getPurchase().length() / 2));
                    run1.addBreak();
                    run1.setText(data.get(i).getSubcontract().substring(data.get(i).getPurchase().length() / 2));
                }
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(2).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getSubcontracted());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(3).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getPurchase().substring(0, data.get(i).getPurchase().length() / 2));
                run1.addBreak();
                run1.setText(data.get(i).getPurchase().substring(data.get(i).getPurchase().length() / 2));
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(4).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getMaterialCategory());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(5).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getDescribes());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(6).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getExtend());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(7).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();

                //工程名称拆分，每行5个字
                String[] splitProjectName = data.get(i).getProjectName().split("(?<=\\G.{5})");
                for (String s : splitProjectName) {
                    run1.setText(s);
                    run1.addBreak();
                }

//                run1.setText(data.get(i).getProjectName());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
                paragraphs = carRow3.getCell(8).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getUnit());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(9).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
                paragraphs = carRow3.getCell(9).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getQuantity().toString());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(9).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(10).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getFinalUnitPrice());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(11).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(11).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                BigDecimal matchingQuota = new BigDecimal(data.get(i).getMatchingQuota().toString());
                run1.setText(matchingQuota.toString());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(11).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(12).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
                paragraphs = carRow3.getCell(12).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getNotes());
                run1.setFontSize(8);
                run1.setFontFamily("微软雅黑");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(12).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            }
            //输出到C盘

            FileOutputStream os = new FileOutputStream(fileName);
            doc.write(os);
            os.close();
        }
        return fileName;
    }

    //抚州导出审批表
    public static String approvalWordFuZhou(List<Choose> data, XWPFDocument doc) throws Exception {
        String fileName = "C:\\dataFile\\bidResultTable\\" + data.get(0).getDemandUnit() + "匹配审批表" + data.get(0).getOrderId() + ".docx";
        {
/*            XWPFParagraph p = doc.createParagraph();
            //设置分页符
            p.setPageBreak(true);*/
            //创建段落================标题
            XWPFParagraph paragraph = doc.createParagraph();
            //设置对齐
            paragraph.setAlignment(ParagraphAlignment.LEFT);
            // 表格
            XWPFTable table = doc.createTable(data.size() + 1, 11);
            //表格属性
            CTTblPr tablePr = table.getCTTbl().addNewTblPr();
            //表格宽度
            CTJc cTJc = tablePr.addNewJc();
            //居中
            cTJc.setVal(STJc.CENTER);
            //列宽自动分割
            CTTblWidth tableWidth = tablePr.addNewTblW();
            //设置表格宽度
            tableWidth.setType(STTblWidth.DXA);
            tableWidth.setW(BigInteger.valueOf(15000));
            //========================================第一行===================================
            //设置单元格宽度
            XWPFTableRow carRow1 = table.getRow(0);
            //设置单元格高度
            carRow1.setHeight(500);
            //设置单元格宽度
            carRow1.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));

            //以创建段落的方式给单元格赋值
            List<XWPFParagraph> paragraphs = carRow1.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            XWPFRun run1 = paragraphs.get(0).createRun();
            run1.setText("序号");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(1).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物资名称");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(2).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物料描述");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(3).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("工程项目名称");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
            paragraphs = carRow1.getCell(4).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("单位");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
            paragraphs = carRow1.getCell(5).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("数量");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(6).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("拟匹配供应商");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
            paragraphs = carRow1.getCell(7).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("税率");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
            paragraphs = carRow1.getCell(8).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税单（元）");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(9).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
            paragraphs = carRow1.getCell(9).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税总价（元）");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(9).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
            paragraphs = carRow1.getCell(10).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("备注");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            for (int i = 0; i < data.size(); i++) {
                XWPFTableRow carRow3 = table.getRow(i + 1);

                carRow3.setHeight(500);
                carRow3.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
                paragraphs = carRow3.getCell(0).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("" + (i + 1));
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(1).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getSubcontracted());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(2).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getDescribes());
                run1.addBreak();
                run1.setText(data.get(i).getExtend());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(3).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getProjectName());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
                paragraphs = carRow3.getCell(4).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getUnit());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
                paragraphs = carRow3.getCell(5).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getQuantity().toString());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(6).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getCompanyName());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
                paragraphs = carRow3.getCell(7).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getTaxRate());
                //工程名称拆分，每行5个字
/*                String[] splitProjectName = data.get(i).getProjectName().split("(?<=\\G.{5})");
                for (String s : splitProjectName) {
                    run1.setText(s);
                    run1.addBreak();
                }*/
//                run1.setText(data.get(i).getProjectName());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
                paragraphs = carRow3.getCell(8).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getFinalUnitPrice());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(9).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(800));
                paragraphs = carRow3.getCell(9).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getMatchingQuota().toString());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(9).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(10).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(500));
                paragraphs = carRow3.getCell(10).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getNotes());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                run1.setBold(true);
                carRow3.getCell(10).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }
            //输出到C盘

            FileOutputStream os = new FileOutputStream(fileName);
            doc.write(os);
            os.close();
        }
        return fileName;
    }

    //中选通知书
    public static String createWord(List<Choose> data, XWPFDocument doc) throws Exception {
        String fileName = "C:\\dataFile\\bidResultTable\\中选通知书" + data.get(0).getOrderId() + ".docx";
        {
            XWPFParagraph p = doc.createParagraph();
            //设置分页符
            p.setPageBreak(true);
            //创建段落================标题
            XWPFParagraph paragraph = doc.createParagraph();
            //设置对齐
            paragraph.setAlignment(ParagraphAlignment.LEFT);
            //相同属性得区域
            XWPFRun run = paragraph.createRun();
            run.setColor("000000");
            run.setText("附件:");
            run.setFontFamily("黑体");
            run.setFontSize(26);
            run.setBold(true);
            //换行
//            run.addBreak();
            //表格标题
            paragraph = doc.createParagraph();
            paragraph.setAlignment(ParagraphAlignment.CENTER);
            run = paragraph.createRun();
            run.setFontSize(16);
            run.setText("中标通知书（详情）");
            run.setBold(true);
            run.setFontFamily("黑体");
            run.addBreak();
            // 表格
            XWPFTable table = doc.createTable(data.size() + 5, 9);
            //      XWPFTable table = doc.createTable(data.size()+1, 13);
            //表格属性
            CTTblPr tablePr = table.getCTTbl().addNewTblPr();
            //表格宽度
            CTJc cTJc = tablePr.addNewJc();
            //居中
            cTJc.setVal(STJc.CENTER);
            //列宽自动分割
            CTTblWidth tableWidth = tablePr.addNewTblW();
            //设置表格宽度
            tableWidth.setType(STTblWidth.DXA);
            tableWidth.setW(BigInteger.valueOf(10000));
            //========================================第一行===================================
            //设置单元格宽度
            XWPFTableRow carRow1 = table.getRow(0);
            //设置单元格高度
            carRow1.setHeight(500);
            //设置单元格宽度
            carRow1.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));

            //以创建段落的方式给单元格赋值
            List<XWPFParagraph> paragraphs = carRow1.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            XWPFRun run1 = paragraphs.get(0).createRun();
            run1.setText("工程名称");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(1).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物资名称");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(2).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("物料描述");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(3).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("扩展描述");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(4).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("单位");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(5).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("数量");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(6).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("需求单位");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(7).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("含税成交价（元）");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow1.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow1.getCell(8).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            XWPFTableRow carRow2 = table.getRow(1);
            carRow2.setHeight(500);
            for (int i = 0; i < 7; i++) {
                carRow2.setHeight(500);
                carRow2.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow2.getCell(i).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("");
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setBold(true);
                run1.setColor("000000");
                carRow1.getCell(i).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }
            carRow2.setHeight(500);
            carRow2.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow2.getCell(7).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("单价");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow2.setHeight(500);
            carRow2.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow2.getCell(8).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("总价");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setBold(true);
            run1.setColor("000000");
            carRow1.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            BigDecimal totalPrice = new BigDecimal(Double.toString(0.00));
            for (int i = 0; i < data.size(); i++) {
                XWPFTableRow carRow3 = table.getRow(i + 2);

                carRow3.setHeight(500);
                carRow3.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(0).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();

                //工程名称拆分，每行5个字
                String[] splitProjectName = data.get(i).getProjectName().split("(?<=\\G.{5})");
                for (String s : splitProjectName) {
                    run1.setText(s);
                    run1.addBreak();
                }

//                run1.setText(data.get(i).getProjectName());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(1).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getMaterialCategory());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(2).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(2).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getDescribes());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(2).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(3).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(3).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getExtend());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(3).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(4).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(4).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getUnit());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(4).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(5).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(5).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getQuantity().toString());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(5).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(6).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(6).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                //需求单位名称，一行4个字
                String[] split = data.get(i).getDemandUnit().split("(?<=\\G.{4})");
                for (String s : split) {
                    run1.setText(s);
                    run1.addBreak();
                }
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(6).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(7).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(7).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText(data.get(i).getFinalUnitPrice());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(7).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                carRow3.setHeight(500);
                carRow3.getCell(8).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow3.getCell(8).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                BigDecimal matchingQuota = new BigDecimal(data.get(i).getMatchingQuota().toString());
                run1.setText(matchingQuota.toString());
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
//                run1.setBold(true);
                carRow3.getCell(8).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

                totalPrice = totalPrice.add(matchingQuota);
            }

            XWPFTableRow carRow4 = table.getRow(data.size() + 2);
            carRow4.setHeight(500);
            carRow4.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow4.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.CENTER);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("总计");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setColor("000000");
            carRow4.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);

            carRow4.getCell(1).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow4.getCell(1).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.LEFT);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            String amountWords = ConvertUpMoney.toChinese(totalPrice.toString());
            run1.setText("人民币：" + amountWords + "（¥" + totalPrice + "元）");
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setColor("000000");
            carRow4.getCell(1).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            for (int i = 2; i < 9; i++) {
                //         carRow4.setHeight(800);
                carRow4.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow4.getCell(i).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.LEFT);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("");
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                carRow4.getCell(i).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }
            XWPFTableRow carRow5 = table.getRow(data.size() + 3);
            carRow5.setHeight(500);
            carRow5.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow5.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.LEFT);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            run1.setText("   供应商联系人：" + data.get(0).getContacts() + "  " + data.get(0).getContactInformation());
            run1.addBreak();
            //    run1.setText("   需求单位联系人： 张晓东 13507047159");
            run1.setText("   需求单位联系人：" + data.get(0).getPersonName() + "   " + data.get(0).getPersonTelephone());
            run1.addBreak();
            run1.setText("   需求单位收货人：" + data.get(0).getConsigneeName() + "  " + data.get(0).getConsigneeTelephone());
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setColor("000000");
            carRow5.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            for (int i = 1; i < 9; i++) {
                //         carRow4.setHeight(800);

                carRow5.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow5.getCell(i).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.LEFT);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("");
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                carRow5.getCell(i).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }

            XWPFTableRow carRow6 = table.getRow(data.size() + 4);
            carRow6.setHeight(500);
            carRow6.getCell(0).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
            paragraphs = carRow6.getCell(0).getParagraphs();
            paragraphs.get(0).setAlignment(ParagraphAlignment.LEFT);
            paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
            run1 = paragraphs.get(0).createRun();
            if (data.get(0).getIsStatePrice()) {
                run1.setText("本次采购将履行国网省管产业商城下单流程，国网智联电商有限公司0.8%服务费由招标人支付");
            }
            run1.setFontSize(10);
            run1.setFontFamily("宋体");
            run1.setColor("000000");
            carRow6.getCell(0).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            for (int i = 1; i < 9; i++) {
                //         carRow4.setHeight(800);
                carRow6.getCell(i).getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(1000));
                paragraphs = carRow6.getCell(i).getParagraphs();
                paragraphs.get(0).setAlignment(ParagraphAlignment.LEFT);
                paragraphs.get(0).setVerticalAlignment(TextAlignment.CENTER);
                run1 = paragraphs.get(0).createRun();
                run1.setText("");
                run1.setFontSize(10);
                run1.setFontFamily("宋体");
                run1.setColor("000000");
                carRow5.getCell(i).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
            }

            //合并列
            mergeHorizontal(table, 0, 7, 8);
            mergeHorizontal(table, data.size() + 2, 1, 8);
            mergeHorizontal(table, data.size() + 3, 0, 8);
            mergeHorizontal(table, data.size() + 4, 0, 8);
            //合并行
            mergeVertically(table, 0, 0, 1);
            mergeVertically(table, 1, 0, 1);
            mergeVertically(table, 2, 0, 1);
            mergeVertically(table, 3, 0, 1);
            mergeVertically(table, 4, 0, 1);
            mergeVertically(table, 5, 0, 1);
            mergeVertically(table, 6, 0, 1);

            if (!data.get(0).getIsStatePrice()) {
                mergeVertically(table, 0, data.size() + 3, data.size() + 4);
            }
            //合并项目单位，需求单位
            mergeVertically(table, 0, 2, data.size() + 1);
            mergeVertically(table, 6, 2, data.size() + 1);

            //输出到C盘
            FileOutputStream os = new FileOutputStream(fileName);
            doc.write(os);
            os.close();
        }
        return fileName;
    }

    //合并列
    public static void mergeVertically(XWPFTable table, int col, int fromRow, int toRow) {
        for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
            XWPFTableCell cell = table.getRow(rowIndex).getCell(col);
            if (rowIndex == fromRow) {
                cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART);
            } else {
                cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
            }
        }
        //合并后垂直居中
        table.getRow(fromRow).getCell(col).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
    }

    //合并行
    public static void mergeHorizontal(XWPFTable table, int row, int fromCell, int toCell) {
        for (int cellIndex = fromCell; cellIndex <= toCell; cellIndex++) {
            XWPFTableCell cell = table.getRow(row).getCell(cellIndex);
            if (cellIndex == fromCell) {
                cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
            } else {
                cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
            }
        }
    }

}
